/**
 * FormFieldTreeCheckbox
 * zTree API官网：https://treejs.cn/v3/api.php
 */
layui.define(['FormFieldTreeCheck'], function (exports) {

    let FormFieldTreeCheck = layui.FormFieldTreeCheck;

    class FormFieldTreeCheckbox extends FormFieldTreeCheck {

        constructor(options = {}) {
            super(options);
            this.mode = "checkbox";
        }

        defineExtraArgs() {
            return {
                nodes: [],
                closeLevel: 0,
                lastChecked: false,
                correlation: [true,true,true,true], // 关联关系，[]bool{勾选时关联父,勾选时关联子,取消勾选时关联父,取消勾选时关联子}。默认关联所有
            };
        }

        handleArgs(args) {
            let that = this;
            // nodes
            that.handleArgsByNodes(args);
            // verify
            if (args.verify.indexOf("arrayIn") === -1)
                args.verify += (args.verify ? "|" : "") + `arrayIn:${that.getArgsAllowNodeIds(args).join(",")}`;
            // correlation
            if (!yunj.isArray(args.correlation)) {
                args.correlation = [];
            }
            let i = args.correlation.length;
            while (i < 4) {
                args.correlation.push(true);
                i++;
            }
            return args;
        }
        
    }

    exports('FormFieldTreeCheckbox', FormFieldTreeCheckbox);
});